<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ref</title>
</head>
<body>
    <script src="../vue@2.6.14.min.js"></script>
    <div id="app">
        <h3>demo1</h3>
        <p ref="ref1" v-text="text">
            
        </p>
        <button @click="getP">点击获取p标签</button>
        <button @click="updateP">修改p标签中的内容</button>
    </div>
    <script>
        var vm = new Vue({
            el: '#app',
            data() {
                return {
                    text: '这是一段文案',
                }
            },
            methods: {
                getP() {
                    // 获取到的是p标签
                    console.log('@@:', this.$refs.ref1);
                },
                updateP() {
                    this.text = '这段文案被修改了！';
                }
            }
        })
        // 获取到的是p标签
        console.log(vm.$refs.ref1);
    </script>
    <h3>
        <ol>
            <li>
                特殊属性ref，相当于id属性，用于获取标签元素。<br>
                
            </li>
        </ol>
    </h3>
</body>
</html>